/**
 * 分类模块路由文件
 */

const Router = require('koa-router');
const router = new Router();
const { validate, validPage, messages } = require('../validators/common');
const { add, del, getAll } = require('../services/picture');
const { authorization } = require('./common');
const joi = require('joi');

/**
 * 校验搜索
 */
const validSearch = joi.object({
    start_date: joi.date().label('起始时间').allow('', null).messages(messages),
    end_date: joi.date().label('结束时间').allow('', null).messages(messages)
}).concat(validPage);

router.prefix('/picture');

router.post('/add', authorization('pictureAdd'), add);

router.delete('/delete/:id', authorization('pictureDelete'), del);

router.get('/get', authorization('pictureGet', 'pictureAdd', 'goodsSearch', 'goodsAdd'), validate(validSearch), getAll);

module.exports = router;